home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari Mega Archive 1
/
Atari Mega Archive - Volume 1.iso
/
mint
/
lib
/
mntlib44.zoo
/
mntlib
/
getpass.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-10-12
|
767b
|
44 lines
#include <ioctl.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <limits.h>
extern int __mint;
char *
getpass(prompt)
const char *prompt;
{
static char buf[PASS_MAX + 1];
char *ret;
struct sgttyb oldsb, newsb;
FILE *tty;
int ttyfd;
fflush(stdin);
tty = stdin;
if (__mint) {
if ((tty = fopen("U:\\DEV\\TTY", "r")) == NULL)
return NULL;
}
ttyfd = fileno(tty);
fflush(tty);
gtty(ttyfd, &oldsb);
newsb = oldsb;
newsb.sg_flags &= ~ECHO;
stty(ttyfd, &newsb);
fputs(prompt, stderr);
fflush(stderr);
if ((ret = fgets(buf, PASS_MAX + 1, tty)) != 0)
{
/* zap the newline */
if (buf[strlen(buf) - 1] == '\n')
buf[strlen(buf) - 1] = 0;
}
stty(ttyfd, &oldsb);
if (__mint)
(void) fclose(tty);
return ret;
}